package com.cheng.example.book.advise151.chap5.client70;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 *  1、Arrays.copyOf（ 或 System.arraycopy）复制确实是浅克隆，只复制了对象的引用（内存地址），并没有为每个元素新创建对象！
 */
@Data
public class Student {

    private String name;

    private int age;


    public static void main(String[] args) {

        List<Student> students = new ArrayList<>();
        Student student = new Student();
        student.setName("chengshuai");
        students.add(student);

        List<Student> studentList = new ArrayList<>(students);
        studentList.get(0).setName("zhangsan");

        System.out.println(students.get(0).getName());
    }
}
